
function f_get_create_sql()
{   #处理sql文件, 将所有sql放在一行, 去掉 /**/ 这种注释, 以及comment的'' ""内的串, 用于判断是否有除了create以外的sql
    declare fun_name
    fun_name="f_get_create_sql"
    { cat ${alter_file}|grep -Ev -- "^--|^#"|grep -Pv -- "^[ \t]{1,}(--|#)"|tr "\n" " "|sed -r 's#/\*[^*]+\*/##g'|f_delete_for_string > ${alter_file_tmp2};} || true
    cat ${alter_file_tmp2}|tr ";" "\n"|sed 's#/\**\*/##g'|sed 's/^[ \t]*//g;s/$/;/g'|sed "/^;$/d"|awk '{for(i=1;i<=NF;i++)printf $i " ";printf"\n"}' > ${alter_file_tmp1}
    if [ "$(grep -vicP "^[ \t]*create (table|index) " ${alter_file_tmp1})x" != "0x" ]
    then
        grep -viP "^[ \t]*create (table|index) " ${alter_file_tmp1} || true
        f_logging "$(eval echo ${log_addr}):ERROR" "您的需求是建表, 但是提交的sql语句中, 存在其他类型sql(如上显示), 请检查后重新提交" "2" "1"
    elif [ "$(grep -icP "^[ \t]*create table " ${alter_file_tmp1})x" == "0x" ]
    then
        f_logging "$(eval echo ${log_addr}):ERROR" "您的需求是建表, 但是提交的sql语句中, 没有建表语句, 请检查后重新提交" "2" "1"
    fi

    cat ${alter_file}|${test_mysql_comm} ${test_db} -NBf >/dev/null 2> ${sql_exe_error}
    if [ "$(grep -ic "error" ${sql_exe_error})x" != "0x" ]
    then
        [ -f "${sql_exe_error}" ] && __="$(sed '/Using a password/d' ${sql_exe_error})"
        f_logging "$(eval echo ${log_addr}):ERROR" "提交的建表语句存在如上所示的语法错误, 请检查后重新提交 ] [ ${__}" "2" "1"
    fi

    table_name_list=($(${test_mysql_comm} ${test_db} -NBe "show tables;" 2>/dev/null)) || true
    for table_name in ${table_name_list[@]}
    do
        f_check_mysql_for_key_word "${table_name}" "表名" "table" "null"
        f_check_index_info "${table_name}" &
    done

    _table_name_list="$(awk '{split($0,a," ");for(i=1;i<=length(a);i++){if (length(a)==1){str=a[i]}else if(i==1){str=a[i]"'\'',"}
        else if(i==length(a)) {str="'\''"a[i]}else{str="'\''"a[i]"'\'',"}printf str}print ""}' <<< "${table_name_list[@]}")"
    table_name_is_use=($(f_exe_sql_in_test_mysql "show tables;" "" "$(eval echo ${log_addr})" 2>/dev/null)) || true
    f_check_table_name_is_use "${_table_name_list}" || f_exit "1"
    f_check_table_for_batch "${_table_name_list}"

    if [ "${all_sql_is_ok}x" == "0x" ] && [ "${check_mode_opt}x" == "strictx" ]
    then
        f_record_info_to_dbadb "create" "test" "测试遇到未知失败. 详情请看${localhost_ip}:${log_file}" || true
        f_logging "$(eval echo ${log_addr}):ERROR" "提交的sql文件未通过检测, 请按照上面的提示做出相应的修改您检查" "2" "1"
    elif [ "${all_sql_is_ok}x" == "0x" ]
    then
        f_logging "$(eval echo ${log_addr}):WARN" "提交的sql文件未通过检测, 但是没有使用 '-o strict' 的检查模式, 将继续相应的操作"
    elif [ "${all_sql_is_ok}x" == "1x" ]
    then
        f_logging "$(eval echo ${log_addr}):INFO" "提交的sql文件通过检测, 在测试环境创建完成"
    else
        f_logging "$(eval echo ${log_addr}):WARN" "遇到未知的错误" "2" "1"
    fi

    if [ "${execute}x" != "1x" ]
    then
        if [ "${execute_opt}x" != "1x" ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "测试环境执行通过, 如需在生产环境执行, 请在原来参数的基础上加 '-e 1' " "2"
        else
            f_logging "$(eval echo ${log_addr}):REMAIND" "测试环境执行通过, 下面准备在生产环境执行"
        fi
        return 0
    fi

    f_logging "$(eval echo ${log_addr}):REMAIND" "现在开始在 '${mysql_host}:${mysql_port}' 环境执行提交的建表语句"
    for table_name in ${table_name_list[@]}
    do
        table_name="\`${table_name}\`"
        f_exe_sql_in_test_mysql "show create table ${test_db}.${table_name}\G" "" "$(eval echo ${log_addr})"|awk '{if (NR>2) print $0}END{print ";"}'
    done > ${alter_file_tmp2}

    cat ${alter_file_tmp2}|${mysql_comm} ${mysql_db} 2> ${sql_exe_error} && exe_state="${?}" || exe_state="${?}"

    if [ ${exe_state} -eq 0 ]
    then
        __="提交的建表语句, 都已经在 '${mysql_host}:${mysql_port}' 环境执行成功"
        echo "[ $(date "+%F %H:%M:%S") ] [ 成功 ] [ ${localhost_ip} ] [ ${__} ]"|tee -a ${log_file}
        f_exit "0"
    else
        f_record_info_to_dbadb "create" "execute" "遇到未知失败. 详情请看${localhost_ip}:${log_file}" || true
        [ -f "${sql_exe_error}" ] && __="$(sed '/Using a password/d' ${sql_exe_error})"
        f_logging "$(eval echo ${log_addr}):ERROR" "提交的建表语句, 在 '${mysql_host}:${mysql_port}' 环境执行失败 ] [ ${__}" "2" "1"
    fi
    return 0
}


